<?php
class GuestBook_EditController extends Crb_Controller
{
	
   public function preDispatch()
   {
        parent::preDispatch();
        $this->view->Title = 'Редактирование гостевой книги';
        $this->view->layout()->setLayout('admin');
   }
    
    public function viewAction()
    {
        $ID = $this->_request->getParam('id',0);
        $News = new News();
        $oneNews = $News->getOne($ID);
        $this->view->Row = $oneNews; 
        $this->view->Title = $oneNews['Title']; 
    }
    

   	public function indexAction()
	{
		$News = new GuestBook();
		$News = $News->getList();
				$this->view->News = $News;
		$this->view->Title = "Гостевая книга"; 
	}
	
    
	
	public function approveAction()
    {
    	$this->setNoRender();
    	$this->disableLayout();
    	
        $ID = $this->_request->getParam('id',0);
        $IDS = $this->_request->getParam('ids',array());
    	$guestBookDAO = new GuestBook();
    	
    	$guestBookDAO->approve($ID);
    	
    	foreach ($IDS as $id)
    	{
    	    $guestBookDAO->approve($id);
    	}
    } 
    
    
    public function removeAction()
    {
    	$this->setNoRender();
    	$this->disableLayout();
    	
        $ID = $this->_request->getParam('id',0);
        $IDS = $this->_request->getParam('ids',array());
        
    	$guestBookDAO = new GuestBook();
    	
    	$guestBookDAO->reject($ID);
    	
        foreach ($IDS as $id)
    	{
    	    $guestBookDAO->reject($id);
    	}
    } 
}